<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="layout" content="bocMain"/>
    <title>进件作业系统</title>
</head>

<body>
<header class="header-title">资产负债信息</header>
<g:form action="contactAssetInfoSave" method="post" class="myForm weui-label-12">
    <input type="hidden" name="id" id="id" value="${this?.opportunity?.id}">

    <div class="weui-cells weui-cells_form">
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">银行往来情况</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="bankDealings" name="contact.bankDealings"
                          from="${com.next.Contact.constrainedProperties.bankDealings.inList}"
                          value="${this.opportunity?.contact?.bankDealings}" noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">成为中行客户时间</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="beCustomerDuration" name="contact.beCustomerDuration"
                          from="${com.next.Contact.constrainedProperties.beCustomerDuration.inList}"
                          value="${this.opportunity?.contact?.beCustomerDuration}"
                          noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">主借款人月收入</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" name="contact.monthlyIncome" id="monthlyIncome"
                       value="${this.opportunity?.contact?.monthlyIncome}" placeholder="请输入"/>
            </div>

            <div class="weui-cell__hd"><label class="weui-label rightUnit">元</label></div>
        </div>


        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">借款人月收入类型</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="monthlyIncomeType" name="contact.monthlyIncomeType"
                          from="${com.next.Contact.constrainedProperties.monthlyIncomeType.inList}"
                          value="${this.opportunity?.contact?.monthlyIncomeType}"
                          noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <g:textField class="weui-input hide" id="monthlyIncomeVerifyMethod" name="contact.monthlyIncomeVerifyMethod" placeholder="请输入" value="${this.opportunity?.contact?.monthlyIncomeVerifyMethod}"/>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">借款人月收入验证方式</label></div>
            <div class="weui-cell__bd agree-group">
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" value="收入证明">收入证明
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" value="银行卡流水">银行卡流水<br>
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" value="社保记录">社保记录
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" value="公积金记录">公积金记录<br>
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" value="纳税记录">纳税记录
                <input type="checkbox" class="weui-agree__checkbox" name="incomeItem" id="monthlyIncomeOther" value="其他">其他
            </div>
        </div>

        <div class="weui-cell hide" id="monthlyIncomeVerifyMethodActive">
            <div class="weui-cell__hd"><label class="weui-label">借款人月收入其他验证方式</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="monthlyIncomeVerifyMethodMemo"
                       name="contact.monthlyIncomeVerifyMethodMemo"
                       value="${this?.opportunity?.contact?.monthlyIncomeVerifyMethodMemo}" placeholder="请输入"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">家庭其他成员月收入</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" id="otherMembersMonthlyIncome"
                       name="contact.otherMembersMonthlyIncome"
                       value="${this.opportunity?.contact?.otherMembersMonthlyIncome}" placeholder="请输入"/>
            </div>

            <div class="weui-cell__hd"><label class="weui-label rightUnit">元</label></div>
        </div>

        <g:textField class="weui-input hide" id="otherMembersMonthlyIncomeVerifyMethod" name="contact.otherMembersMonthlyIncomeVerifyMethod" placeholder="请输入" value="${this.opportunity?.contact?.otherMembersMonthlyIncomeVerifyMethod}"/>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">家庭其他成员月收入验证方式</label></div>
            <div class="weui-cell__bd agree-group">
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" value="收入证明">收入证明
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" value="银行卡流水">银行卡流水<br>
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" value="社保记录">社保记录
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" value="公积金记录">公积金记录<br>
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" value="纳税记录">纳税记录
                <input type="checkbox" class="weui-agree__checkbox" name="othersIncomeItem" id="otherMembersMonthlyIncomeOther" value="其他">其他
            </div>
        </div>

        <div class="weui-cell hide" id="otherDiv">
            <div class="weui-cell__hd"><label class="weui-label">借款人家庭成员月收入其他验证方式</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="othersIncomeVerifyMemo"
                       name="contact.othersIncomeVerifyMemo"
                       value="${this?.opportunity?.contact?.othersIncomeVerifyMemo}" placeholder="请输入"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">家庭总收入</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" name="contact.monthlyTotalIncome" id="monthlyTotalIncome" value="${this.opportunity?.contact?.monthlyTotalIncome}" readonly="true" />
            </div>

            <div class="weui-cell__hd"><label class="weui-label rightUnit">元</label></div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">客户特征</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="contactCharacter" name="contact.contactCharacter"
                          from="${com.next.Contact.constrainedProperties.contactCharacter.inList}"
                          value="${this.opportunity?.contact?.contactCharacter}"
                          noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">是否提供居留证明</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="isProvideResidentCertificate"
                          name="contact.isProvideResidentCertificate"
                          from="${[[name: '是', value: true], [name: '否', value: false]]}" optionKey="value"
                          optionValue="name" value="${this?.opportunity?.contact?.isProvideResidentCertificate}"
                          noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">现有住房种类</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.houseType" id="houseType"
                          value="${this.opportunity?.contact?.houseType?.id}" optionKey="id"
                          optionValue="name" from="${com.next.HouseType.list()}" noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">持卡情况</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="cardCountRange" name="contact.cardCountRange"
                          from="${com.next.Contact.constrainedProperties.cardCountRange.inList}"
                          value="${this.opportunity?.contact?.cardCountRange}" noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">家庭成员数量</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" id="familyMembersCount" name="contact.familyMembersCount"
                       value="${this.opportunity?.contact?.familyMembersCount}" placeholder="请输入"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">供养人口数</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" id="fendCount" name="contact.fendCount"
                       value="${this.opportunity?.contact?.fendCount}" placeholder="请输入"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">消贷关联客户标记</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="contactMarkupOfConsumerLoan"
                          name="contact.contactMarkupOfConsumerLoan"
                          from="${com.next.Contact.constrainedProperties.contactMarkupOfConsumerLoan.inList}"
                          value="${this.opportunity?.contact?.contactMarkupOfConsumerLoan}"
                          noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">消贷客户来源</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="contactSourceOfConsumerLoan"
                          name="contact.contactSourceOfConsumerLoan"
                          from="${com.next.Contact.constrainedProperties.contactSourceOfConsumerLoan.inList}"
                          value="${this.opportunity?.contact?.contactSourceOfConsumerLoan}"
                          noSelection="${['': '请选择']}"></g:select>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">客户级别</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="name4" name="name4" value="00" placeholder="00"
                       readonly="true"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">个人客户信用等级</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="text" id="name3" name="name3" value="未评级" placeholder="未评级"
                       readonly="true"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">是否提供任职单位营业执照</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" id="isProvideBusinessLicense" name="contact.isProvideBusinessLicense"
                          from="${[[name: '是', value: true], [name: '否', value: false]]}" optionKey="value"
                          optionValue="name" value="${this?.opportunity?.contact?.isProvideBusinessLicense}"
                          noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">关联客户标志</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" id="name1" name="name1" value="9" placeholder="请输入"
                       readonly="true"/>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">非法记录标注</label></div>

            <div class="weui-cell__bd">
                <input class="weui-input" type="number" id="name2" name="name2" value="9" placeholder="请输入"
                       readonly="true"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">客户特征标签1</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.contactFeatureCategory" id="contactFeatureCategory"
                          value="${this.opportunity?.contact?.contactFeatureCategory?.id}" optionKey="id"
                          optionValue="name" from="${com.next.ContactFeatureCategory.list()}"
                          noSelection="${['': '请选择']}"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">客户特征标签2</label></div>

            <div class="weui-cell__bd">
                <g:select class="weui-select" name="contact.contactFeature" id="contactFeature"
                          value="${this.opportunity?.contact?.contactFeature?.id}" optionKey="id"
                          optionValue="name" from="${contactFeatureList}" noSelection="${['': '请选择']}"/>
            </div>
        </div>
    </div>
</g:form>

<div class="bigBtn">
    <button type="button" class="weui-btn weui-btn_primary" id="submit">下一步</button>
</div>

<script>

    $(function () 
    {
        $("input[name='incomeItem']").on("click", function () {
            var vIds = "";
            $("input[name='incomeItem']:checked").each(function() {
                vIds += $(this).val() + ",";
            });
            if (vIds.length > 0) {
                vIds = vIds.substring(0, vIds.length - 1);
            }
            $("#monthlyIncomeVerifyMethod").val(vIds);
        });

        $("input[name='othersIncomeItem']").on("click", function () {
            var vIds = "";
            $("input[name='othersIncomeItem']:checked").each(function() {
                vIds += $(this).val() + ",";
            });
            if (vIds.length > 0) {
                vIds = vIds.substring(0, vIds.length - 1);
            }
            $("#otherMembersMonthlyIncomeVerifyMethod").val(vIds);
        });

    });

    $('#monthlyIncomeOther').click(function() 
    {
        if($('#monthlyIncomeOther').is(':checked'))
        {
            $('#monthlyIncomeVerifyMethodActive').removeClass("hide");
        }
        else
        {
            $('#monthlyIncomeVerifyMethodActive').addClass("hide");
            $("#monthlyIncomeVerifyMethodMemo").val("");
        }
    })

    $('#otherMembersMonthlyIncomeOther').click(function() 
    {
        if($('#otherMembersMonthlyIncomeOther').is(':checked'))
        {
            $('#otherDiv').removeClass("hide");
        }
        else
        {
            $('#otherDiv').addClass("hide");
            $("#othersIncomeVerifyMemo").val("");
        }
    })
        
    $("#monthlyIncome").blur(function()
    {
        var monthlyIncome = $("#monthlyIncome").val();
        var otherMembersMonthlyIncome = $("#otherMembersMonthlyIncome").val();
        if (monthlyIncome && otherMembersMonthlyIncome)
        {
            $('#monthlyTotalIncome').val(parseFloat(monthlyIncome) + parseFloat(otherMembersMonthlyIncome));
        }
    })

    $("#otherMembersMonthlyIncome").blur(function()
    {
        var monthlyIncome = $("#monthlyIncome").val();
        var otherMembersMonthlyIncome = $("#otherMembersMonthlyIncome").val();
        if (monthlyIncome && otherMembersMonthlyIncome)
        {
            $('#monthlyTotalIncome').val(parseFloat(monthlyIncome) + parseFloat(otherMembersMonthlyIncome));
        }
    })

    $("#submit").click(function () {

        // var fullName1 = $("#fullName1").val();
        // if (!fullName1) {
        //     helpMessage("请输入联系人1姓名");
        //     return;
        // }

        // var cellphone1 = $("#cellphone1").val()
        // if (!cellphone1) {
        //     helpMessage("请输入联系人1手机号码");
        //     return;
        // }

        // var opportunityContactType1 = $("#opportunityContactType1").val()
        // if (!opportunityContactType1) {
        //     helpMessage("请输入联系人1类型");
        //     return;
        // }

        // var fullName2 = $("#fullName2").val();
        // if (!fullName2) {
        //     helpMessage("请输入联系人2姓名");
        //     return;
        // }

        // var cellphone2 = $("#cellphone2").val()
        // if (!cellphone2) {
        //     helpMessage("请输入联系人2手机号码");
        //     return;
        // }

        // var opportunityContactType2 = $("#opportunityContactType2").val()
        // if (!opportunityContactType2) {
        //     helpMessage("请输入联系人2类型");
        //     return;
        // }

        $(".myForm").submit();
    })

    $("#contactFeatureCategory").bind("change", function () {
        $("#contactFeature option").remove();
        $("#s2id_contactFeature span:first").html("请选择");
        var category = $("#contactFeatureCategory").val()
        $("#contactFeature").append("<option value='' >请选择</option>")
        if (category == '-1' || category == '') {
            return
        }
        $.ajax({
            url: "/bocAppOpportunity/getContactFeatureByCategoryId",
            type: "POST",
            data: {'category': category},
            success: function (result) {
                console.log(result)
                for (var i = 0; i < result.contactFeatureList.length; i++) {
                    $("#contactFeature").append("<option value=" + result.contactFeatureList[i][0] + ">" + result.contactFeatureList[i][1] + "</option>")
                }
            }
        });
    });

    function helpMessage(message) {
        $(".helpMsg").text(message).fadeIn(200);
        setTimeout(function () {
            $(".helpMsg").fadeOut(200);
        }, 2000);
    }
</script>
</body>
</html>
